package com.kylin.common.saas.configuration;

import com.kylin.common.saas.filter.SaasTenantFilter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 多租户模式自动装配配置
 * @author wuhao
 * @version 1.0 - 2024/2/28
 */
@Configuration
@EnableConfigurationProperties(SaaSProperties.class)
public class SaaSAutoConfiguration {

    @Bean(name = "tenantFilter")
    @ConditionalOnProperty(prefix = "kylin.saas", value = "enable", havingValue = "true", matchIfMissing = true)
    public SaasTenantFilter tenantFilter() {
        return new SaasTenantFilter();
    }
}
